<template>
	<view>
		<u-navbar :title="title" back-icon-size='44' :border-bottom='false'></u-navbar>
		<view>
			<u-gap height="28" bg-color="#F2F2F7"></u-gap>
		</view>
		<view class="plane">
			<view class="top">
				<view class="type">
					单程
				</view>
				<view class="planeid">
					<text>{{airObj.company}}{{airObj.flightNo}}</text>
				</view>
				<view class="time">
					{{airObj.depTime.split(' ')[1]}}
				</view>
				<view class="howtime">
					总时长 {{totalTime}}
				</view>
			</view>
			<view class="midle">
				<view class="start">
					<view class="time">
						{{airObj.depTime.split(' ')[1]}}
					</view>
					<view class="address">
						{{airObj.depPort}}
					</view>
				</view>
				<image class="airTo" src="../../../static/imgs/airTo.png" mode=""></image>
				<view class="stop">
					<view class="time">
						{{airObj.arrTime.split(' ')[1]}}
					</view>
					<view class="address">
						{{airObj.arrPort}}
					</view>
				</view>
			</view>
			<view class="beizu">
				<text v-if="airObj.meal">有小食</text> | {{airObj.planeSize == 1?'大':''}}型机
			</view>
		</view>
		<view>
			<u-gap height="28" bg-color="#F2F2F7"></u-gap>
		</view>
		<view class="planeTab">
			<view class="planeTab-item" :class="{active:curtab == 0}" style="margin-right: 86rpx;" @click="tabFn(0)"
				v-if="type==2">
				<view class="title">
					经济舱
				</view>
				<view :class="{line:curtab == 0}"></view>
			</view>
			<view class="planeTab-item" :class="{active:curtab == 1}" @click="tabFn(1)" v-if="type == 1">
				<view class="title">
					公务/头等舱
				</view>
				<view class="planeTab-line" :class="{line:curtab == 1}"></view>
			</view>
			<view class="logo" v-if="type == 1">
				享专享定制服务
			</view>
		</view>
		<view class="planeCont" v-if="curtab == 0">
			<view class="content-ul">
				<view class="content-li" v-for="(item,index) in airObj.seatItems" :key='index'
					v-if="item.cabinClass !=1 && item.cabinClass !=2">
					<view class="left" v-if="item.policys.priceDatas[0].welfareFund !=0">
						<view class="price">
							<view class="y-price">
								<text style="font-size: 24rpx;">¥</text>{{item.policys.priceDatas[0].price}}
							</view>
							<view class="flj">
								<text>福利金抵扣</text>
								<text style="font-size: 20rpx;margin-left: 10rpx;">¥</text>
								<text>{{item.policys.priceDatas[0].welfareFund}}</text>
							</view>
							<view class="s-price">
								实付 ¥ {{item.policys.priceDatas[0].price-item.policys.priceDatas[0].welfareFund}}
							</view>
						</view>
						<view class="other" v-if="item.discount>0&& item.discount<1">
							{{item.seatMsg}} {{Number(item.discount*10).toFixed(1)}}折
						</view>
					</view>

					<view class="left" v-else>
						<view class="price">
							<view class="y-price">
								<text style="font-size: 24rpx;">¥</text>{{item.policys.priceDatas[0].price}}
							</view>
						</view>
						<view class="other" v-if="item.discount>0&& item.discount<1">
							{{item.seatMsg}} {{Number(item.discount*10).toFixed(1)}}折
						</view>
					</view>

					<view class="rightBtn"
						@click="navTo('./buyOrder?id='+ item.policys.policyId+'&type='+item.policys.productType+'&cwType='+'&price='+item.policys.priceDatas[0].price +'&airTax='+item.policys.priceDatas[0].airportTax+'&cwTxet='+item.seatMsg+'&seatCode='+item.seatCode+'&seatStatus='+item.seatStatus+'&flj='+item.policys.priceDatas[0].welfareFund)">
						预定
					</view>
				</view>
			</view>
		</view>

		<view class="planeCont" v-if="curtab == 1">
			<view class="content-ul">
				<view class="content-li" v-for="(item,index) in airObj.seatItems" :key='index'
					v-if="item.cabinClass == 2 || item.cabinClass ==1">
					<view class="left">
						<view class="price">
							<view class="y-price">
								<text style="font-size: 24rpx;">¥</text>{{item.policys.priceDatas[0].price}}
							</view>
							<view class="flj">
								<text>福利金抵扣</text>
								<text style="font-size: 20rpx;margin-left: 10rpx;">¥</text>
								<text>{{item.policys.priceDatas[0].welfareFund}}</text>
							</view>
							<view class="s-price">
								实付 ¥ {{item.policys.priceDatas[0].price-item.policys.priceDatas[0].welfareFund}}
							</view>
						</view>
						<view class="other" v-if="item.discount>0&& item.discount<1">
							{{item.seatMsg}} {{Number(item.discount*10).toFixed(1)}}折
						</view>
					</view>
					<view class="rightBtn"
						@click="navTo('./buyOrder?id='+ item.policys.policyId+'&type='+item.policys.productType+'&cwType='+'&price='+item.policys.priceDatas[0].price +'&airTax='+item.policys.priceDatas[0].airportTax+'&cwTxet='+item.seatMsg+'&seatCode='+item.seatCode+'&seatStatus='+item.seatStatus+'&flj='+item.policys.priceDatas[0].welfareFund)">
						预定
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import utils from '@/common/utils.js'
	export default {
		data() {
			return {
				curtab: 0,
				list: [1, 2, 3],
				airObj: {},
				title: '',
				totalTime: '',
				type: ''
			}
		},
		onLoad(option) {
			this.type = option.cwType
			if (this.type == 1) {
				this.curtab = 1
			}
		},
		onShow() {
			if (this.$store.state.airDetail) {
				let addre = this.$store.state.searchJp
				this.title = addre.startAddr + '-' + addre.endAddr
				this.airObj = this.$store.state.airDetail
				let totalTime = utils.countDown(this.airObj.depTime, this.airObj.arrTime)
				this.totalTime = totalTime[1] + 'h' + totalTime[2] + 'm'
			}
		},
		methods: {
			navTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			tabFn(val) {
				this.curtab = val
			}
		}
	}
</script>


<style lang="scss" scoped>
	.plane {
		width: 100%;
		height: 320rpx;
		background-color: #FFFFFF;

		.top {
			display: flex;
			align-items: center;
			padding-top: 42rpx;
			padding-left: 28rpx;

			.type {
				width: 68rpx;
				height: 32rpx;
				background: #2D8AF8;
				border-radius: 8px;
				text-align: center;
				font-size: 20rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 32rpx;
				margin-right: 20rpx;
			}

			.time,
			.howtime {
				font-size: 24rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #333333;
				margin-right: 20rpx;
			}

			.planeid {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #333333;
				margin-right: 20rpx;

				image {
					margin-right: 6rpx;
					width: 32rpx;
					height: 32rpx;
				}
			}
		}

		.midle {
			padding-top: 30rpx;
			padding-left: 116rpx;
			display: flex;
			align-items: center;

			.airTo {
				width: 100rpx;
				height: 12rpx;
				margin: 0 64rpx;
			}

			.start,
			.stop {
				.time {

					font-size: 44rpx;
					font-family: Alibaba Sans;
					font-weight: bold;
					color: #333333;
				}

				.address {
					font-size: 28rpx;
					font-family: Segoe UI;
					font-weight: bold;
					color: #333333;
					margin-top: 8rpx;
				}
			}
		}

		.beizu {
			text-align: center;
			margin-top: 42rpx;
			font-size: 24rpx;
			font-family: Segoe UI;
			font-weight: 400;
			color: #999999;
		}
	}

	.planeTab {
		width: 100%;
		height: auto;
		background: #FFFFFF;
		display: flex;
		padding: 20rpx 28rpx;

		.logo {
			width: 180rpx;
			height: 32rpx;
			background: linear-gradient(60deg, #F7E5A7 0%, #EDC883 100%);
			border-radius: 4rpx;
			font-size: 20rpx;
			font-family: Segoe UI;
			font-weight: 400;
			color: #514023;
			text-align: center;
			margin-top: 6rpx;
			margin-left: 14rpx;
		}

		.planeTab-item {
			color: #333333;
			display: flex;
			flex-direction: column;
			align-items: center;

			&.active {
				color: #3587F7;
			}

			.title {
				font-size: 32rpx;
				font-family: Segoe UI;
				font-weight: bold;
			}

			.price {
				font-size: 24rpx;
				font-family: Segoe UI;
				font-weight: 400;
				padding: 6rpx 0;
			}

			.line {
				width: 96rpx;
				height: 6rpx;
				background: #3587F7;
				border-radius: 40rpx;
			}
		}
	}

	.planeCont {
		padding: 16rpx 28rpx 0;

		.content-ul {
			.content-li {
				width: 694rpx;
				height: 160rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				display: flex;
				padding: 0 28rpx;
				align-items: center;
				margin-bottom: 16rpx;

				.left {
					.price {
						display: flex;
						align-items: center;

						.y-price {
							font-size: 32rpx;
							font-family: Arial;
							font-weight: 400;
							color: rgba(153, 153, 153, 0.5);
						}

						.flj {
							display: flex;
							align-items: center;
							margin-left: 10rpx;
							font-size: 28rpx;
							font-family: Arial;
							font-weight: 400;
							color: #FAC48F;
						}

						.s-price {
							margin-left: 20rpx;
							font-size: 28rpx;
							font-family: Arial;
							font-weight: 400;
							color: #333333;
						}
					}

					.other {
						margin-top: 10rpx;
						font-size: 24rpx;
						font-family: Segoe UI;
						font-weight: 400;
						color: #333333;
					}

				}


				.rightBtn {
					margin-left: auto;
					width: 136rpx;
					height: 64rpx;
					background: linear-gradient(126deg, #F5B053 0%, #F8912C 100%);
					border-radius: 40rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 600;
					line-height: 64rpx;
					color: #FFFFFF;
					text-align: center;
				}

			}
		}
	}
</style>
